#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include <time.h>
#include <math.h>

#define MAX 1000000000
void main (void)
{

    srand48(time(NULL));

    int i;
    long double x,y;

    mpf_set_default_prec(33219281);

    mpf_t total_p,in_p,pie;

    mpf_init(total_p);
    mpf_set_ui(total_p,0);

    mpf_init(pie);
    mpf_set_ui(pie,0);

    mpf_init(in_p);
    mpf_set_ui(in_p,0);

    for(i = 0; i < MAX; i++)
    {
        x = (long double)rand()/RAND_MAX;
        y = (long double)rand()/RAND_MAX;

        if(((x*x) + (y*y)) <= 1.0)
        {
            mpf_add_ui(in_p,in_p,1);
        }
        mpf_add_ui(total_p,total_p,1);
    }
    mpf_mul_ui(in_p,in_p,4);
    mpf_div(pie,in_p,total_p);
    mpf_clear (total_p);
    mpf_clear (in_p);

    gmp_printf("Pi %.100Ff \n",pie);
    mpf_clear (pie);


}
